﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using CashShop.Bussiness;
namespace CashShop
{
    public partial class Form1 : Form
    {
        private CashFacade cf = new CashFacade();
        private decimal totalPirce = 0.00M;
        public Form1()
        {
            InitializeComponent();
        }

        private void cbxType_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void Form1_Load(object sender, EventArgs e)
        {
            //读取xml文件，绑定下拉菜单
            cbxType.DataSource = cf.GetCashAcceptTypeLiat();
            cbxType.SelectedIndex = 0;

        }
        //重置
        private void butReset_Click(object sender, EventArgs e)
        {
            totalPirce = 0.00M;
            txbPrice.Text = "";
            txbCount.Text = "";
            lbList.Items.Clear();
            lblResult.Text = "￥0.00";
            cbxType.SelectedIndex = 0;

        }
        //确定
        private void btnOK(object sender, EventArgs e)
        {
            var total = 0.00M;
            total = cf.GetTotalPrice(cbxType.SelectedItem.ToString(),
                Convert.ToDecimal(txbPrice.Text) * Convert.ToDecimal(txbCount.Text));
            totalPirce += total;
            lbList.Items.Add(" 单价: " + txbPrice.Text + " 数量: " + txbCount.Text + " " + cbxType.SelectedItem + " 合计: " +
                             total.ToString("C"));
            lblResult.Text = totalPirce.ToString("C");
        }
    }
}
